#include "GameMesh.h"

GameMesh::GameMesh()
{
	m_core = 0;
	m_attPos = 0;
	m_attCen = 0;
}

GameMesh::~GameMesh()
{
	shut();
}

void GameMesh::init(
	char* a_meshPath,
	clkColor a_color,
	V3DF a_position,
	V3DF a_rotation,
	V3DF a_scaling,
	V3DF a_center)
{
	m_core = clkCore::getInstance();
	m_core->createMesh(&m_mesh,a_meshPath);
	m_color = a_color;
	m_position = a_position;
	m_rotation = a_rotation;
	m_scaling = a_scaling;
	m_center = a_center;
}

void GameMesh::shut()
{

}

void GameMesh::draw(
	int a_rotateType,
	V3DF a_rotateLook)
{
	bool flag = false;
	if(a_rotateType == CLK_ROTATE_LOOKAT
		|| a_rotateType == CLK_ROTATE_LOOKTO)
		flag = true;

	if(m_attPos)
		m_position = (*m_attPos)+m_attPosOff;
	if(m_attCen)
		m_center = (*m_attCen)+m_attCenOff;

	m_core->drawMesh(
		&m_mesh,
		m_position,
		(!flag)?m_rotation:a_rotateLook,
		m_scaling,
		m_center,
		m_color,
		a_rotateType);
}